package com.ls.cloud.auth.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;

import javax.persistence.Id;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * @author: candy33
 * @Date: 2022/05/11 22:23
 * com.ls.cloud.auth.entity
 */
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "system_user")
@Where(clause = "deleted = 0")
public class AuthUser implements Serializable {

    @Id
    @Column(name = "id", nullable = false, columnDefinition = "VARCHAR(32) COMMENT '主键'")
    @JsonIgnore
    private String id;

    @Column(name = "login_times", columnDefinition = "INT(11) DEFAULT 0 COMMENT '用户登录次数'")
    private int loginTimes;

    @Column(name = "admin", nullable = false, columnDefinition = "TINYINT(1) DEFAULT 0 COMMENT '是否最高管理员'")
    private Boolean admin;

    @JsonIgnore
    @Column(name = "username", nullable = false, columnDefinition = "VARCHAR(30) COMMENT '用户登录名'")
    private String username;

    @JsonIgnore
    @Column(name = "password", nullable = false, columnDefinition = "VARCHAR(100) COMMENT '用户密码'")
    private String password;

    @JsonIgnore
    @Column(name = "login_ip", columnDefinition = "VARCHAR(15) DEFAULT '' COMMENT '用户登录的IP地址'")
    private String loginIp;

    @JsonIgnore
    @Column(name = "login_date", columnDefinition = "DATETIME COMMENT '用户登录的时间'")
    private Date loginDate;

    @JsonIgnore
    @Column(name = "last_login_ip", columnDefinition = "VARCHAR(15) DEFAULT '' COMMENT '用户上次登录的IP地址'")
    private String lastLoginIp;

    @JsonIgnore
    @Column(name = "last_login_date", columnDefinition = "DATETIME COMMENT '用户上次登录的时间'")
    private Date lastLoginDate;
}
